//
//  ByJobViewModel.m
//  jmsfhz_ios
//
//  Created by pro on 16/8/3.
//  Copyright © 2016年 pro. All rights reserved.
//

#import "ByJobViewModel.h"

#import "ByNetJobApi.h"

@implementation ByJobViewModel

- (void)jobQuery:(ByNetParamsModel *)params {
    
    void (^failure)(ByNetBaseResult *result) = nil;
    
    if([self.jobDelegate respondsToSelector:@selector(jobQueryFailure:)]) {
        
        failure = ^(ByNetBaseResult *result){
            [self.jobDelegate jobQueryFailure:result];
        };
    }
    
    [ByNetJobApi jobQuery:params success:^(ByNetBaseResult *result) {
        if (self.jobDelegate) {
            [self.jobDelegate jobQuerySuccess:result];
        }
    } failure:failure];
}

- (void)jobSend:(ByNetParamsModel *)params {
    
    void (^failure)(ByNetBaseResult *result) = nil;
    
    if([self.jobSendDelegate respondsToSelector:@selector(jobSendFailure:)]) {
        
        failure = ^(ByNetBaseResult *result){
            [self.jobSendDelegate jobSendFailure:result];
        };
    }
    
    [ByNetJobApi jobSend:params success:^(ByNetBaseResult *result) {
        if (self.jobSendDelegate) {
            [self.jobSendDelegate jobSendSuccess:result];
        }
    } failure:failure];

}
- (void)jobThatMySend:(ByNetParamsModel *)params {
    
    void (^failure)(ByNetBaseResult *result) = nil;
    
    if([self.jobThatMySendDelegate respondsToSelector:@selector(jobThatMySendFailure:)]) {
        
        failure = ^(ByNetBaseResult *result){
            [self.jobThatMySendDelegate jobThatMySendFailure:result];
        };
    }
    
    [ByNetJobApi jobThatMySend:params success:^(ByNetBaseResult *result) {
        if (self.jobThatMySendDelegate) {
            [self.jobThatMySendDelegate jobThatMySendSuccess:result];
        }
    } failure:failure];
}



@end
